<template>
	<view class="warp">
		<view class="title">
			{{info.websiteTitle}}
		</view>
		<view class="image" style="text-align: center;">
			<image :src="info.websiteImage" mode="widthFix"></image>
		</view>
		<!-- <view class="context" v-html="info.websiteContent">
			 
		</view> -->
		<view class="" style="padding: 0 10rpx;">
			<jyfParser :html="info.websiteContent" :isAll="true"></jyfParser>
		</view>
		<view class="zanzhunum">
			<view class="content">
				<uni-icons color="#fff" type="eye" size="20"></uni-icons>
		           <view class="num">
		           	<span>浏览量:</span>
					<span>{{info.websiteRedisViews}}</span>
		           </view>
			</view>
		</view>
	</view>
</template>

<script>
	import {mapState,mapMutations} from 'vuex';
	import jyfParser from '@/components/jyf-parser/jyf-parser'
	export default {
		components:{
				jyfParser,
		},
		data() {
			return {
				info:{},
				id:'',
				starttime:'',
				endtime:'',
				timelong:'',
				memberId:'',
				storeId:'',
				shopId:'',
			};
		},
		onLoad(options) {
			this.id= this.$Route.query.id
			this.memberId=this.$Route.query.memberId
			this.storeId=this.$Route.query.storeId
			this.shopId=this.$Route.query.shopId
					if(this.storeId){
			 			uni.setStorageSync('storeId', this.storeId);
			 		}
					if(this.shopId){
						uni.setStorageSync('shopId', this.shopId);
					}
			 // 保存推荐人id
			 if(this.memberId){
			 	uni.setStorageSync('referrerId', this.memberId);
			 }
			this.getinfo({id:this.id})
		},
		computed: {
					...mapState(['hasLogin', 'userInfo', 'userCenterData']),
					},
					onShow() {
						// #ifdef MP-WEIXIN
											 // if(!this.hasLogin){
												// this.getLogin()
												
											 // }
						// #endif
							this.starttime=new Date().getTime()
					},
					onHide() {
							this.endtime=new Date().getTime()
							this.timelong=this.endtime-this.starttime
							if(this.hasLogin){
								this.addcustomer()
							}
							
							
							},
		onShareAppMessage:function(){
			let pathinfo=''
			let limag=this.info.websiteImage
			if(this.userCenterData.memberId){
				 pathinfo=`/webcont/ximageinfo/ximageinfo?id=${this.id}&memberId=${this.userCenterData.memberId}&storeId=${this.userCenterData.vendorId}&shopId=${this.userCenterData.storeId}`
			}else{
				 pathinfo=`/webcont/ximageinfo/ximageinfo?id=${this.id}`
			}
			// let pathinfo='/extra/activityList/activityList'
			return{
				title: this.info.websiteTitle,
				path:pathinfo,
				imageUrl: limag,
			}
		},
		onShareTimeline: function() {
			let pathinfo=''
			let limag=this.info.websiteImage
			if(this.userCenterData.memberId){
				 pathinfo=`/webcont/ximageinfo/ximageinfo?id=${this.id}&memberId=${this.userCenterData.memberId}&storeId=${this.userCenterData.vendorId}&shopId=${this.userCenterData.storeId}`
			}else{
				 pathinfo=`/webcont/ximageinfo/ximageinfo?id=${this.id}`
			}
			// let pathinfo='/extra/activityList/activityList'
			return{
				title: this.info.websiteTitle,
				path:pathinfo,
				imageUrl: limag,
			}
		},
		mounted() {
			// vm.obj.NewsContent = vm.obj.NewsContent.replace(/<img/g, "<img mode='widthFix' style='max-width:600rpx;height:auto;'");
			// this.$nextTick(() => {
				
			//      // const images = this.$refs.context.querySelectorAll('img');
			//    const images=document.getElementsByName("img")
			// 	 images.forEach(img => {
			//        img.setAttribute('mode', 'widthFix'); // 修改mode属性为'widthFix'
			//         console.log(img);
			// 						  });
			//    });
		},
		methods:{
			getinfo(val){
				this.$request({
					url:"v3/website/front/member/detail?websiteId="+val.id,
					method:'GET',
				}).then(res=>{
					this.info=res.data
					
					// 。。。
				})
			},
			
			timechange(time){
			 	 //时间戳为10位需*1000，时间戳为13位的话不需乘1000
			 	  var date = new Date(time);
			 	  var Y = date.getFullYear() + '-';
			 	  var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth()+1) : date.getMonth() + 1) + '-';
			 	  var D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' ';
			 	  var h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours()) + ':';
			 	  var m = (date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes())+ ':';
			 	  var s = (date.getSeconds() < 10 ? '0'+date.getSeconds() : date.getSeconds());
			 	  return  Y + M + D + h + m + s;
			 },
			// 添加
			addcustomer(){
				if(this.info.websiteId){
					let pnone=uni.getDeviceInfo()
						
						let param={}
						
						param.data=
						{
							address:uni.getStorageSync('address'),//地址
							avatar:this.userCenterData.memberAvatar,//头像
							birthday:'2023-11-09',//生日
							browGoods:this.info.websiteTitle,//活动名称
							browGoodsId:this.info.websiteId,//商品id
							browTime:(this.timelong/1000).toFixed(1),
							company:'',//公司
							createBy:this.userCenterData.memberName,
							createTime:this.timechange(new Date()),
							cusCustomerIntention:'3',//客户意向方（0-高意向，1-中意向，2-低意向）
							cusDealOrNot:'1',//(0-已成交，1-未成交)
							// cusFollowStage:'0',//跟进阶段(0-初步沟通，1-确定意向，2-等待付款)
							customerDescription:'',//	客户描述
							customerName:this.userCenterData.memberName,//客户姓名
							email:this.userCenterData.memberEmail,//邮箱
							jobTitle:'',//职务名称
							phoneAddress:uni.getStorageSync('address'),//手机号地址
							phoneNum:this.userCenterData.memberMobile,//手机号
							referrerId:this.memberId,
							referrerUsername:'',
							scoreUsername:'协会动态',//渠道
							sex:this.storeId,//性别
							source:'0',//来源
							wechatId:'',//微信号
							wechatName:'',//微信昵称
							temporaryId:pnone.deviceId,
							// customerTaskId:this.$Route.query.taskId,
							// customerIndexId:this.$Route.query.indexId,
						}
						
						param.url='v3/customer/front/appCustomer'
						param.method="POST"
						param.header={
						  'Content-Type': 'application/json'
						}
						// param.data=JSON.stringify(param.data)
						console.log(param);
						this.$request(param)
				}
			
				
			},
		}
	}
</script>

<style lang="scss" scoped>
page{
			width: 750rpx;
			margin: 0 auto;
			background: #F5F5F5;
			
		}
		
		.warp{
			border-top: 2rpx solid #cecece;
			padding: 10rpx 20rpx;
			background-color: #fff;
			
			.title{
				margin-top: 10rpx;
				padding: 10rpx;
				font-size: 32rpx;
				font-weight: 550;
				margin-bottom: 10rpx;
				text-align: center;
			}
			.context{
				margin-bottom: 10rpx;
				padding: 10rpx;
				font-size: 30rpx;
				width: 750rpx;
			}
			
			.zanzhunum{
				position: fixed;
				top: 25%;
				right: 10rpx;
				.content{
					border-radius: 10rpx;
					padding: 10rpx;
					display: flex;
					align-items: center;
					background-color:rgba(0, 0, 0, 0.2);
					.num{
						margin-left: 10rpx;
						color: #fff;
					}
				}
			}
			 
			
		}
</style>
